package tw.com.diary.core;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import tw.com.diary.ae.com.DirayBussinessException;
import tw.com.diary.ae.com.Msg;
import tw.com.diary.api.com.Contract;
import tw.com.diary.api.domain.MainDTO;
import tw.com.diary.api.service.MainService;

public class MainServiceImpl implements MainService {

	@Override
	public void login(MainDTO dto, Context context)
			throws DirayBussinessException {
		final String password = dto.getPasssword();

		final SharedPreferences share = context.getSharedPreferences(
				Contract.USER_SETTING, 0);

		final String realPasssord = share.getString(Contract.PASSWORD,
				Contract.DEF_PASSWORD);

		if (!TextUtils.equals(password, realPasssord)) {
			throw new DirayBussinessException(Msg.W0005);
		}

	}

}
